package valueObject;

import entity.Role;
import entity.User;
import java.util.ArrayList;
import java.util.Collection;

/**
 *
 * @author Juan Hernández Serrato
 */
public class RoleVO implements ValueObject<Role> {
    private Integer idRole;
    private String name;
    private Collection<UserVO> userCollection;
    
    @Override
    public Role toEntity() {
        Role role = new Role();
        role.setIdRole(idRole);
        role.setRoleName(name);
        ArrayList<User> users = new ArrayList<User>();
        if(userCollection != null){
            for(UserVO u : userCollection){
                users.add(u.toEntity());
            }
        }
        role.setUserCollection(users);
        return role;
    }

    public Integer getId() {
        return idRole;
    }

    public void setId(Integer idRole) {
        this.idRole = idRole;
    }

    public String getName() {
        return name;
    }

    public void setName(String roleName) {
        this.name = roleName;
    }

    public Collection<UserVO> getUsers() {
        return userCollection;
    }

    public void setUsers(Collection<UserVO> userCollection) {
        this.userCollection = userCollection;
    }

}
